package com.yss.sofa.report.engine.cell.invisible.dataset;

import java.io.Serializable;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.yss.sofa.report.engine.Const;
import com.yss.sofa.report.engine.Context;
import com.yss.sofa.report.engine.DataSet;
import com.yss.sofa.report.engine.DataSetData;
import com.yss.sofa.report.engine.cell.ReportCell;
import com.yss.sofa.report.engine.cell.invisible.InvisibleCell;

public class StaticDataSetCell extends InvisibleCell implements DataSet{
	private static final long serialVersionUID = 6582158524986532417L;
	private static final Logger LOGGER=LoggerFactory.getLogger(StaticDataSetCell.class);
	private String begin;
	private String end;
	private DataSetData data;
	private String exec;
	protected void init() {
		super.init();
		this.type=Const.REPORT_CELL_TYPE_STATIC_DATASET;
		this.exec="true";
	}
	public void assignTo(ReportCell cell){
		StaticDataSetCell _=(StaticDataSetCell)cell;
		super.assignTo(_);
		_.begin=this.begin;
		_.end=this.end;
		_.exec=this.exec;
		_.data=this.data;
	}
	public StaticDataSetCell create(){
		StaticDataSetCell _=new StaticDataSetCell();
		this.assignTo(_);
		return _;
	}
	public Set<String> getParams() {
		return null;
	}

	public DataSetData execute(String classname,Context context, Map<String, Serializable> params,Map<String,String> consts) throws Exception {
		if(data.size()>10000){
			LOGGER.warn("静态数据集["+code+"]返回的数据已超过10000条");
		}
		return data;
	}

	public DataSetData getData() {
		return data;
	}

	public void setData(DataSetData data) {
		this.data = data;
	}

	public String getBegin() {
		return begin;
	}

	public void setBegin(String begin) {
		this.begin = begin;
	}

	public String getEnd() {
		return end;
	}

	public void setEnd(String end) {
		this.end = end;
	}
	public String getExec() {
		return exec;
	}
	public void setExec(String exec) {
		this.exec = exec;
	}
}
